//
//  XCBottomView.swift
//  XCMicroBo
//
//  Created by 1 on 16/3/12.
//  Copyright © 2016年 1. All rights reserved.
//

import UIKit
import SnapKit

class XCBottomView: UIView {

    
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        //测试背景颜色
        backgroundColor = UIColor.greenColor()
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI(){
        
        addSubview(retweetBtn)
        addSubview(commentBtn)
        addSubview(goodClickBtn)
        
        //创建临时视图  作为按钮的分割线
        let line1 = UIView()
        line1.backgroundColor = UIColor.blackColor()
        let line2 = UIView()
        line2.backgroundColor = UIColor.blackColor()
        addSubview(line1)
        addSubview(line2)
        
        
        //设置约束 使  按钮平均分配
        
        retweetBtn.snp_makeConstraints { (make) -> Void in
            
            make.left.top.bottom.equalTo(self)
            make.width.equalTo(goodClickBtn)
        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            
            make.top.bottom.equalTo(self)
            
            make.left.equalTo(retweetBtn.snp_right)
            
            make.width.equalTo(retweetBtn.snp_width)
        }
        
        goodClickBtn.snp_makeConstraints { (make) -> Void in
            
            make.right.bottom.top.equalTo(self)
            
            make.left.equalTo(commentBtn.snp_right)
            
            make.width.equalTo(commentBtn.snp_width)
        }
    
        
        line1.snp_makeConstraints { (make) -> Void in
            
            make.left.equalTo(retweetBtn.snp_right)
            
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            
            make.centerY.equalTo(self.snp_centerY)

            
            make.width.equalTo(0.5)
        }
        
        line2.snp_makeConstraints { (make) -> Void in
            

            make.left.equalTo(commentBtn.snp_right)
            
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
            
            make.centerY.equalTo(self.snp_centerY)

            make.width.equalTo(0.5)
        }

    }
    
    
    //懒加载按钮
    lazy var retweetBtn = UIButton.buttonWithTitle("转发", textFont: 14, textColor: UIColor.darkGrayColor(), image: "timeline_icon_retweet", backImage: nil)
    lazy var commentBtn = UIButton.buttonWithTitle("评论", textFont: 14, textColor: UIColor.darkGrayColor(), image: "timeline_icon_comment", backImage: nil)
    
    lazy var goodClickBtn = UIButton.buttonWithTitle("点赞", textFont: 14, textColor: UIColor.darkGrayColor(), image: "timeline_icon_unlike", backImage: nil)
}
